package com.monkey4cloud.study.webfluxdemo001.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

@RestController
@Slf4j
@RequiredArgsConstructor
@SecurityScheme(name = "登录", type = SecuritySchemeType.HTTP, scheme = "basic")
public class HelloController {
    @GetMapping
    public Mono<String> hi() {
        return Mono.just("hello Gemiman");
    }

    @PreAuthorize("hasAnyAuthority('admin')")
    @GetMapping("test_admin")
    @Operation(summary = "test admin", security = @SecurityRequirement(name = "登录"), tags = {"admin"})
    public Mono<String> admin() {
        return Mono.just("hello admin");
    }
}
